﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Lonewolf.Entity;
using Lonewolf.Infrastructure;
using Lonewolf.IService;
using Microsoft.AspNetCore.Mvc;

namespace Lonewolf.WebApp.Controllers
{
    public class RoleController : Controller
    {
        private IRoleInfoService roleInfoService;
        public RoleController(IRoleInfoService roleInfoService)
        {
            this.roleInfoService = roleInfoService;
        }
        public async Task<JsonResult<SaveEntity>> Index()
        {
            Random rd = new Random();
            RoleInfo roleInfo = new RoleInfo
            {
                RoleName = "测试角色" + rd.Next(100, 999)
            };
            return await roleInfoService.SaveAsync(roleInfo);
        }
        [HttpPost]
        public async Task<JsonResult<SaveEntity>> Index(string o)
        {
            RoleInfo roleInfo = new RoleInfo
            {
                Id = "8de69babad2b4e43b682b0a3656c36a0",
                RoleName = "修改测试角色"
            };
            return await roleInfoService.SaveAsync(roleInfo);
        }
        [HttpPost]
        public async Task<JsonResult<string>> Delete(string id)
        {

            return await roleInfoService.DeleteAsync(id.ToStrArray());
        }

    }
}